<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>String.prototype.matchAll</title>
  </head>
  <body>
    <script>
      let str = `<ul>
        <li>
            <a>肖生克的救赎</a>
            <p>上映日期: 1994-09-10</p>
        </li>
        <li>
            <a>阿甘正传</a>
            <p>上映日期: 1994-07-06</p>
        </li>
    </ul>`;

      // 需求：使用正则匹配获电影名称和上映时间
      // 声明正则
      const reg = /<li>.*?<a>(.*?)<\/a>.*?<p>(.*?)<\/p>/gs;
      // 调用方法
      const result = str.matchAll(reg);
      console.log(result);// 返回结果为一个可迭代对象
      for(let v of result){
        console.log(v);
      }

      /* const arr = [...result];
      console.log(arr) */;
    </script>
  </body>
</html>
